package org.song.model.dto.common;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.song.constant.NumberConstant;

import java.io.Serializable;
import java.util.Objects;

@ApiModel(value = "查询DTO父类")
public class BaseSearchDto implements Serializable {
    @ApiModelProperty(value = "当前页数" , notes = "当前页数")
    private Integer page = 1;
    @ApiModelProperty(value = "每页输出条数" , notes = "每页输出条数")
    private Integer size = NumberConstant.MAX_CODE.getIntCode();

    public BaseSearchDto() {}
    public BaseSearchDto(Integer page,Integer size) {
        /*
        * 重点：！！！
        * 在计算机内存中，先开辟对象内存空间 再 调用构造方法！！！！
        * 先开辟对象内存空间 再 执行构造方法！！！！ 否则 this 从哪里来的？
        *
        * */
        this.page = page;
        this.size = size;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BaseSearchDto that = (BaseSearchDto) o;
        return Objects.equals(page, that.page) && Objects.equals(size, that.size);
    }

    @Override
    public int hashCode() {
        return Objects.hash(page, size);
    }

    @Override
    public String toString() {
        return "BaseSearchDto{" +
                "page=" + page +
                ", size=" + size +
                '}';
    }
}
